import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import routes from '@/views/'
 let router = new VueRouter({
    routes:[
        ...routes,
        {path:'/*',redirect:'/'}
    ]
})
router.beforeEach((to,from,next)=>{
    if(to.meta.Jurisdiction){
        localStorage.getItem("token")?next():next('/logion')
    }
    next()
})


// 解决路由重定向报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
export default router